﻿@model Sheng.WeixinConstruction.Management.Shell.Models.OneDollarBuyingDealInfoViewModel

@{
    ViewBag.Title = "OneDollarBuyingDealInfo";
    Layout = "~/Views/Shared/_LayoutBlank.cshtml";
}


<script>

    function deal() {
        var loadLayerIndex = layer.load(0, {
            shade: [0.2, '#fff']
        });

        $.ajax({
            url: "/Api/OneDollarBuying/Deal?saleId=@Model.DealInfo.SaleId",
            type: "POST",
            dataType: "json",
            success: function (data, status, jqXHR) {
                layer.close(loadLayerIndex);
                if (data.Success) {
                    
                    switch (data.Data.Result) {
                        case 0:
                            layerAlert("领取成功！", refresh);
                            break;
                        case 1:
                            layerAlert("该商品已领取过，不可再次领取。");
                            break;
                        case 2:
                            layerAlert("商品信息无效。");
                            break;
                        default:
                            layerAlert("未知：" + data.Data.Result);
                            break;
                    }

                } else {
                    layerAlert(data.Message);
                }
            },
            error: function (xmlHttpRequest) {
                layer.close(loadLayerIndex);
                alert("Error: " + xmlHttpRequest.status);
            }
        });
    }

    function refresh() {
        location.reload();
    }

    function cancel() {
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭
    }
</script>


<div style="margin-left:20px; margin-right:20px; margin-top:20px;">
    <span id="spanTitle" class="font_black_24">@Model.DealInfo.CommodityName</span>
</div>

<div style=" background-color:#ccc; margin-left:20px; margin-right:20px; margin-top:10px; height:1px;">

</div>

<div style=" position:absolute; overflow:auto ;margin-top:25px;left:30px; right:30px; bottom:60px; top:50px; ">

    <form id="form">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td height="36">期号</td>
                <td>@Model.DealInfo.PeriodNumber</td>
            </tr>
            <tr>
                <td width="110" height="36">上架时间：</td>
                <td>@Model.DealInfo.ForSaleTime</td>
            </tr>
            <tr>
                <td height="36">幸运号码</td>
                <td>@Model.DealInfo.LuckyPartNumber</td>
            </tr>
            <tr>
                <td height="36">揭晓时间：</td>
                <td>@Model.DealInfo.DrawTime</td>
            </tr>
            <tr>
                <td height="36">获得者：</td>
                <td>@Model.DealInfo.LuckyMember.NickName</td>
            </tr>
            <tr>
                <td height="36">手机：</td>
                <td>@Model.DealInfo.LuckyMember.MobilePhone</td>
            </tr>
            <tr>
                <td height="36">邮箱：</td>
                <td>@Model.DealInfo.LuckyMember.Email</td>
            </tr>
            <tr>
                <td height="36">是否领取：</td>
                <td>
                    @if (Model.DealInfo.Deal)
                    {
                    @:是
                    }
                    else
                    {
                    @:否
                    }
                </td>
            </tr>
            <tr>
                <td height="36">领取时间：</td>
                <td>@Model.DealInfo.DealTime</td>
            </tr>
        </table>


    </form>

</div>

<div style=" background-color:#ccc; position:absolute; bottom:55px; left:20px;right:20px; height:1px;">

</div>

<div style="position:absolute; bottom:15px; left:20px;right:20px;">

    @if (Model.DealInfo.Deal == false)
    {
        <div style="float:left;">
            <input id="btnDeal" name="btnDeal" type="button" class="btn_green" style="width:200px" value="领 取" onclick="deal()" />
        </div>
    }

    <div style="float:right">
        <input id="btnClose" name="btnClose" type="button" class="btn_blue" value="取 消" onclick="cancel()" />
    </div>
    <div style="clear:both">
    </div>
</div>
